<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>List Literals</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'List Literals' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">runtime</a></li><li><a href="index.html#4">Chapter 4: Enclosed Resources</a></li><li><b>List Literals</b></li></ul></div>
<p class="purpose">Each enclosure contains the literal lists needed by its functions.</p>

<ul class="toc"><li><a href="4-ll.html#SP1">&#167;1. Runtime representation</a></li><li><a href="4-ll.html#SP3">&#167;3. Default values for list kinds</a></li><li><a href="4-ll.html#SP4">&#167;4. Literals</a></li><li><a href="4-ll.html#SP6">&#167;6. The instance list for a kind</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Runtime representation.</b>Literal lists arise from source text such as:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">Q</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> { </span><span class="constant-syntax">60</span><span class="plain-syntax">, </span><span class="constant-syntax">168</span><span class="plain-syntax"> };</span>
</pre>
<p class="commentary">The data to hold <span class="extract"><span class="extract-syntax">{ 60, 168 }</span></span> has to be stored somehow. As with all
kinds for which values cannot be stored in a single word, we use a double
pointer:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">                        </span><span class="identifier-syntax">small</span><span class="plain-syntax"> </span><span class="identifier-syntax">block:</span><span class="plain-syntax">              </span><span class="identifier-syntax">large</span><span class="plain-syntax"> </span><span class="identifier-syntax">block:</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Q</span><span class="plain-syntax"> ----------------&gt; </span><span class="identifier-syntax">pointer</span><span class="plain-syntax"> ----------------&gt; </span><span class="identifier-syntax">block</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">header</span>
<span class="plain-syntax">                        </span><span class="constant-syntax">0</span><span class="plain-syntax">                         </span><span class="identifier-syntax">strong</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">ID</span><span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">entries</span>
<span class="plain-syntax">                                                  </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">entries</span>
<span class="plain-syntax">                                                  </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">entries</span>
</pre>
<p class="commentary">So in this particular example, the result would be:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">                        </span><span class="identifier-syntax">small</span><span class="plain-syntax"> </span><span class="identifier-syntax">block:</span><span class="plain-syntax">              </span><span class="identifier-syntax">large</span><span class="plain-syntax"> </span><span class="identifier-syntax">block:</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Q</span><span class="plain-syntax"> ----------------&gt; </span><span class="identifier-syntax">pointer</span><span class="plain-syntax"> ----------------&gt; </span><span class="identifier-syntax">block</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">header</span>
<span class="plain-syntax">                        </span><span class="constant-syntax">0</span><span class="plain-syntax">                         </span><span class="identifier-syntax">NUMBER_TY</span>
<span class="plain-syntax">                                                  </span><span class="constant-syntax">2</span>
<span class="plain-syntax">                                                  </span><span class="constant-syntax">60</span>
<span class="plain-syntax">                                                  </span><span class="constant-syntax">168</span>
</pre>
<p class="commentary">So the small block always occupies 2 words, the second being initially 0 and
used at runtime; the large block can be any size we need. The runtime code has
elaborate ways to extend or contract dynamic lists, but these of course are
constants, so we simply make the large blocks exactly the right size.
</p>

<p class="commentary">We make the large block first:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">packaging_state</span><span class="plain-syntax"> </span><span class="function-syntax">ListLiterals::begin_large_block</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">ListLiterals::begin_large_block</span></span>:<br/><a href="4-ll.html#SP3">&#167;3</a>, <a href="4-ll.html#SP5_1">&#167;5.1</a>, <a href="4-ll.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">iname</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list_kind</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">no_entries</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">packaging_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">save</span><span class="plain-syntax"> = </span><a href="2-ea.html#SP2" class="function-link"><span class="function-syntax">EmitArrays::begin_word</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">iname</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_value</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-th.html#SP6" class="function-link"><span class="function-syntax">TheHeap::emit_block_value_header</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">list_kind</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><span class="identifier-syntax">no_entries</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-ki.html#SP6" class="function-link"><span class="function-syntax">RTKindIDs::strong_ID_array_entry</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Kinds::unary_construction_material</span><span class="plain-syntax">(</span><span class="identifier-syntax">list_kind</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><a href="2-ea.html#SP4" class="function-link"><span class="function-syntax">EmitArrays::numeric_entry</span></a><span class="plain-syntax">((</span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax">) </span><span class="identifier-syntax">no_entries</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">save</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ListLiterals::end_large_block</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">ListLiterals::end_large_block</span></span>:<br/><a href="4-ll.html#SP3">&#167;3</a>, <a href="4-ll.html#SP5_1">&#167;5.1</a>, <a href="4-ll.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">packaging_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">save</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="2-ea.html#SP5" class="function-link"><span class="function-syntax">EmitArrays::end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">save</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>And then make the small block pointing to it:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="function-syntax">ListLiterals::small_block</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">ListLiterals::small_block</span></span>:<br/><a href="4-ll.html#SP4">&#167;4</a>, <a href="4-ll.html#SP7">&#167;7</a><br/>Default Values - <a href="2-dv.html#SP2_1">&#167;2.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">large_block</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><a href="4-enc.html#SP2" class="function-link"><span class="function-syntax">Enclosures::new_small_block_for_constant</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">packaging_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">save</span><span class="plain-syntax"> = </span><a href="2-ea.html#SP2" class="function-link"><span class="function-syntax">EmitArrays::begin_unchecked</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">N</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-ea.html#SP4" class="function-link"><span class="function-syntax">EmitArrays::iname_entry</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">large_block</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-ea.html#SP4" class="function-link"><span class="function-syntax">EmitArrays::numeric_entry</span></a><span class="plain-syntax">(0);</span>
<span class="plain-syntax">    </span><a href="2-ea.html#SP5" class="function-link"><span class="function-syntax">EmitArrays::end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">save</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Default values for list kinds.</b>The default list is the empty list, but note from the above representation
that the empty list of numbers (say) is different from the empty list of texts:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">          </span><span class="identifier-syntax">small</span><span class="plain-syntax"> </span><span class="identifier-syntax">block:</span><span class="plain-syntax">              </span><span class="identifier-syntax">large</span><span class="plain-syntax"> </span><span class="identifier-syntax">block:</span>
<span class="plain-syntax">    ----&gt; </span><span class="identifier-syntax">pointer</span><span class="plain-syntax"> ----------------&gt; </span><span class="identifier-syntax">block</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">header</span>
<span class="plain-syntax">                                    </span><span class="identifier-syntax">NUMBER_TY</span>
<span class="plain-syntax">                                    </span><span class="constant-syntax">0</span>

<span class="plain-syntax">          </span><span class="identifier-syntax">small</span><span class="plain-syntax"> </span><span class="identifier-syntax">block:</span><span class="plain-syntax">              </span><span class="identifier-syntax">large</span><span class="plain-syntax"> </span><span class="identifier-syntax">block:</span>
<span class="plain-syntax">    ----&gt; </span><span class="identifier-syntax">pointer</span><span class="plain-syntax"> ----------------&gt; </span><span class="identifier-syntax">block</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">header</span>
<span class="plain-syntax">                                    </span><span class="identifier-syntax">TEXT_TY</span>
<span class="plain-syntax">                                    </span><span class="constant-syntax">0</span>
</pre>
<p class="commentary">So each different kind K needs its own large block for making the default value
of "list of K": see <a href="5-ki.html#SP9" class="internal">RTKindIDs::compile_structures</a>. This block is easily made:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ListLiterals::default_large_block</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">ListLiterals::default_large_block</span></span>:<br/>Default Values - <a href="2-dv.html#SP2_1">&#167;2.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">iname</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">list_kind</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">packaging_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">save</span><span class="plain-syntax"> = </span><a href="4-ll.html#SP1" class="function-link"><span class="function-syntax">ListLiterals::begin_large_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">iname</span><span class="plain-syntax">, </span><span class="identifier-syntax">list_kind</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-ll.html#SP1" class="function-link"><span class="function-syntax">ListLiterals::end_large_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">save</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Literals.</b>To return to the example:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">Q</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> { </span><span class="constant-syntax">60</span><span class="plain-syntax">, </span><span class="constant-syntax">168</span><span class="plain-syntax"> };</span>
</pre>
<p class="commentary">Each list literal like <span class="extract"><span class="extract-syntax">{ 60, 168 }</span></span> in imperative code results in a <span class="extract"><span class="extract-syntax">literal_list</span></span>
object, and here we return its value:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="function-syntax">ListLiterals::compile_literal_list</span><span class="plain-syntax">(</span><span class="identifier-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Lists::kind_of_ll</span><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-ll.html#SP2" class="function-link"><span class="function-syntax">ListLiterals::small_block</span></a><span class="plain-syntax">(</span><a href="4-ll.html#SP4" class="function-link"><span class="function-syntax">ListLiterals::large_block_iname</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="function-syntax">ListLiterals::large_block_iname</span><span class="plain-syntax">(</span><span class="identifier-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ll_iname</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ll_iname</span><span class="plain-syntax"> = </span><a href="4-enc.html#SP1" class="function-link"><span class="function-syntax">Enclosures::new_iname</span></a><span class="plain-syntax">(</span><span class="constant-syntax">LITERALS_HAP</span><span class="plain-syntax">, </span><span class="constant-syntax">LIST_LITERAL_HL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">desc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">desc</span><span class="plain-syntax">, </span><span class="string-syntax">"list literal '%W'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">unbraced_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Sequence::queue_at</span><span class="plain-syntax">(&amp;</span><a href="4-ll.html#SP5" class="function-link"><span class="function-syntax">ListLiterals::compilation_agent</span></a><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">STORE_POINTER_literal_list</span><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">), </span><span class="identifier-syntax">desc</span><span class="plain-syntax">, </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">list_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ll_iname</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>The large blocks are then compiled in due course by the following agent
(see <a href="../core-module/1-htc.html" class="internal">How To Compile (in core)</a>):
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ListLiterals::compilation_agent</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">ListLiterals::compilation_agent</span></span>:<br/><a href="4-ll.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">compilation_subtask</span><span class="plain-syntax"> *</span><span class="identifier-syntax">t</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">literal_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ll</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RETRIEVE_POINTER_literal_list</span><span class="plain-syntax">(</span><span class="identifier-syntax">t</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">data</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ll_iname</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Lists::kind_of_ll</span><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="4-ll.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Compile the large block for this literal</span><span class="named-paragraph-number">5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5_1" class="paragraph-anchor"></a><b>&#167;5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile the large block for this literal</span><span class="named-paragraph-number">5.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">llist_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lle</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">lle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">first_llist_entry</span><span class="plain-syntax">; </span><span class="identifier-syntax">lle</span><span class="plain-syntax">; </span><span class="identifier-syntax">lle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">lle</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next_llist_entry</span><span class="plain-syntax">) </span><span class="identifier-syntax">n</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">packaging_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">save</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><a href="4-ll.html#SP1" class="function-link"><span class="function-syntax">ListLiterals::begin_large_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ll_iname</span><span class="plain-syntax">, </span><span class="identifier-syntax">Lists::kind_of_ll</span><span class="plain-syntax">(</span><span class="identifier-syntax">ll</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">), </span><span class="identifier-syntax">n</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">lle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">first_llist_entry</span><span class="plain-syntax">; </span><span class="identifier-syntax">lle</span><span class="plain-syntax">; </span><span class="identifier-syntax">lle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">lle</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next_llist_entry</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">CompileValues::to_array_entry_of_kind</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">lle</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">llist_entry_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">ll</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entry_kind</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-ll.html#SP1" class="function-link"><span class="function-syntax">ListLiterals::end_large_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">save</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-ll.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. The instance list for a kind.</b>For kinds of object and enumerations, Inform sometimes chooses to compile its
own literal list, even though this is not specified anywhere in the source text.
Not all kinds have these: obviously, there can be no instance list for <span class="extract"><span class="extract-syntax">K_real_number</span></span>.
The following returns -1 if <span class="extract"><span class="extract-syntax">K</span></span> is similarly unsuitable, or a non-negative value
for the number of instances it has:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ListLiterals::extent_of_instance_list</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">ListLiterals::extent_of_instance_list</span></span>:<br/><a href="4-ll.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::is_an_enumeration</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="5-kc.html#SP26" class="function-link"><span class="function-syntax">RTKindConstructors::enumeration_size</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::is_subkind_of_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Instances::count</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -1;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>And the following then constructs the literal list, on demand:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="function-syntax">ListLiterals::get_instance_list</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><a href="4-ll.html#SP6" class="function-link"><span class="function-syntax">ListLiterals::extent_of_instance_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">large_block_iname</span><span class="plain-syntax"> = </span><a href="5-kc.html#SP14" class="function-link"><span class="function-syntax">RTKindConstructors::list_iname</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Kinds::get_construct</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">large_block_iname</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">large_block_iname</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><a href="2-hrr.html#SP12" class="function-link"><span class="function-syntax">Hierarchy::make_iname_in</span></a><span class="plain-syntax">(</span><span class="constant-syntax">INSTANCE_LIST_HL</span><span class="plain-syntax">, </span><a href="5-kc.html#SP2" class="function-link"><span class="function-syntax">RTKindConstructors::kind_package</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">packaging_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">save</span><span class="plain-syntax"> = </span><a href="4-ll.html#SP1" class="function-link"><span class="function-syntax">ListLiterals::begin_large_block</span></a><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">large_block_iname</span><span class="plain-syntax">, </span><span class="identifier-syntax">Kinds::unary_con</span><span class="plain-syntax">(</span><span class="identifier-syntax">CON_list_of</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">), </span><span class="identifier-syntax">N</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::is_an_enumeration</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">)) </span><a href="5-kc.html#SP28" class="function-link"><span class="function-syntax">RTKindConstructors::make_enumeration_entries</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::is_subkind_of_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">)) </span><span class="named-paragraph-container code-font"><a href="4-ll.html#SP7_1" class="named-paragraph-link"><span class="named-paragraph">Compile entries for a kind of object</span><span class="named-paragraph-number">7.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><a href="4-ll.html#SP1" class="function-link"><span class="function-syntax">ListLiterals::end_large_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">save</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="5-kc.html#SP14" class="function-link"><span class="function-syntax">RTKindConstructors::set_list_iname</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Kinds::get_construct</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">), </span><span class="identifier-syntax">large_block_iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-ll.html#SP2" class="function-link"><span class="function-syntax">ListLiterals::small_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">large_block_iname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7_1" class="paragraph-anchor"></a><b>&#167;7.1. </b>Note that the instances are given in the order preferred by <a href="2-ic.html" class="internal">Instance Counting</a>,
not in creation order, as a simple <span class="extract"><span class="extract-syntax">LOOP_OVER_INSTANCES</span></span> would have done.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile entries for a kind of object</span><span class="named-paragraph-number">7.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">instance</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax"> = </span><a href="2-ic.html#SP7" class="function-link"><span class="function-syntax">InstanceCounting::next_in_IK_sequence</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><a href="2-ea.html#SP4" class="function-link"><span class="function-syntax">EmitArrays::iname_entry</span></a><span class="plain-syntax">(</span><a href="5-ins.html#SP1" class="function-link"><span class="function-syntax">RTInstances::value_iname</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">I</span><span class="plain-syntax"> = </span><a href="2-ic.html#SP7" class="function-link"><span class="function-syntax">InstanceCounting::next_in_IK_sequence</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-ll.html#SP7">&#167;7</a>.</li></ul>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="4-enc.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-rm.html">1</a></li><li class="progresschapter"><a href="2-hrr.html">2</a></li><li class="progresschapter"><a href="3-gm.html">3</a></li><li class="progresscurrentchapter">4</li><li class="progresssection"><a href="4-enc.html">enc</a></li><li class="progresscurrent">ll</li><li class="progresssection"><a href="4-tl.html">tl</a></li><li class="progresssection"><a href="4-ts.html">ts</a></li><li class="progresssection"><a href="4-rsp.html">rsp</a></li><li class="progresssection"><a href="4-bq.html">bq</a></li><li class="progresssection"><a href="4-rl.html">rl</a></li><li class="progresssection"><a href="4-sal.html">sal</a></li><li class="progresssection"><a href="4-vnl.html">vnl</a></li><li class="progresssection"><a href="4-gt.html">gt</a></li><li class="progresssection"><a href="4-los.html">los</a></li><li class="progresschapter"><a href="5-act.html">5</a></li><li class="progresschapter"><a href="6-bd.html">6</a></li><li class="progresschapter"><a href="7-cg.html">7</a></li><li class="progressnext"><a href="4-tl.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

